package com.ljh.blog.common.utils;

import com.ljh.blog.pojo.dataobject.BlogInfo;
import com.ljh.blog.pojo.dataobject.UserInfo;
import com.ljh.blog.pojo.request.UpdateBlogRequest;
import com.ljh.blog.pojo.response.BlogInfoResponse;
import com.ljh.blog.pojo.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

/**
 * @author: Themberfue
 * @date: 2025/4/1 12:45
 * @description:
 */
public class BeanTransUtils {
    public static BlogInfoResponse trans(BlogInfo blogInfo) {
        if (blogInfo == null) {
            // TODO
            return null;
        }
        BlogInfoResponse blogInfoResponse = new BlogInfoResponse();
        BeanUtils.copyProperties(blogInfo, blogInfoResponse);
        return blogInfoResponse;
    }

    public static UserInfoResponse trans(UserInfo userInfo) {
        if (userInfo == null) {
            // TODO
            return null;
        }
        UserInfoResponse userInfoResponse = new UserInfoResponse();
        BeanUtils.copyProperties(userInfo, userInfoResponse);
        return userInfoResponse;
    }

    public static BlogInfo trans(UpdateBlogRequest updateBlogRequest) {
        if (updateBlogRequest == null) {
            // TODO
            return null;
        }
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(updateBlogRequest, blogInfo);
        return blogInfo;
    }
}
